package com.weixiaodong.ModelDesign.交给子类.FactoryMethod模式.工厂模式实例;


import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * IDCard的工厂类
 */
@SuppressWarnings("all")
public class IDCardFactory extends Factory{

    private Set<String> owners = new HashSet<>();

    @Override
    protected void registerProduct(Product product) {
        owners.add(((IDCard) product).getOwner());
    }

    @Override
    protected Product createProduct(String owner) {
        return new IDCard(owner);
    }

    public boolean hasRegister(String owner) {
        return owners.contains(owner);
    }
}
